<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath%>">
    <title>selectGoods.jsp</title>
    <link href="css/admin/common.css" type="text/css" rel="stylesheet">
    <style type="text/css">
        table{
            text-align: center;
            border-collapse: collapse;
        }
        .bgcolor{
            background-color: #F08080;
        }
    </style>
    <script type="text/javascript">
        function changeColor(obj){
            obj.className = "bgcolor";
        }
        function changeColor1(obj){
            obj.className = "";
        }
    </script>
    <script type="text/javascript">
        function confirmDelete(){
            var n = document.deleteForm.ids.length;
            var count = 0;//统计没有选中的个数
            for(var i = 0; i < n; i++){
                if(!document.deleteForm.ids[i].checked){
                    count++;
                }else{
                    break;
                }
            }
            if(n > 1){
                if(count == n){
                    alert("请选择被删除的资讯！");
                    count = 0;
                    return false;
                }
            }else{
                if(!document.deleteForm.ids.checked){
                    alert("请选择被删除的资讯！");
                    return false;
                }
            }

            if(window.confirm("真的删除吗？really?")){
                document.deleteForm.submit();
                return true;
            }
            return false;
        }
        function checkDel(id){
            if(window.confirm("是否删除该资讯？")){
                window.location.href = "/admin/notice/deleteANotice?noticeId="+id;
            }
        }
    </script>
</head>
<body>
<c:if test="${allRooms.size() == 0 }">
    您还没有资讯。
</c:if>
<c:if test="${allRooms.size() != 0 }">

    <form action="/admin/notice/deleteNotice" name="deleteForm">
        <table border="1" bordercolor="PaleGreen" style="margin-left: 170px">
            <tr>
                <th width="100px">资讯编号</th>
                <th width="200px">资讯标题</th>
                <th width="100">资讯时间</th>
                <th width="100px">操作</th>
            </tr>
            <c:forEach items="${allNotice}" var="notice">
                <tr onmousemove="changeColor(this)" onmouseout="changeColor1(this)">
                    <td><input type="checkbox" name="ids" value="${notice.noticeId}"/>${rooms.roomId }</td>
                    <td>${notice.noticeTitle}</td>
                    <td>${notice.noticeTime}</td>
                    <td><a href="/admin/notice/selectANotice?noticeId=${notice.noticeId}" target="_blank">详情</a>
                        <a href="javascript:checkDel('${notice.noticeId}')">删除</a>
                    </td>

                </tr>
            </c:forEach>
            <tr>
                <td colspan="8">
                    <input type="button" value="删除" onclick="confirmDelete()">
                </td>
            </tr>
            <tr>
                <td colspan="8" align="right">
                    &nbsp;&nbsp;&nbsp;
                    &nbsp;&nbsp;&nbsp;共${totalCount}条记录&nbsp;&nbsp;共${totalPage}页&nbsp;&nbsp;
                    第${pageCur}页&nbsp;&nbsp;
                    <c:url var="url_pre" value="/admin/room/selectAllRooms">
                        <c:param name="pageCur" value="${pageCur - 1 }"/>
                        <c:param name="act" value="deleteSelect"/>
                    </c:url>
                    <c:url var="url_next" value="/admin/room/selectAllRooms">
                        <c:param name="pageCur" value="${pageCur + 1 }"/>
                        <c:param name="act" value="deleteSelect"/>
                    </c:url>
                    <!-- 第一页没有上一页 -->
                    <c:if test="${pageCur != 1 }">
                        <a href="${url_pre}">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
                    </c:if>
                    <!-- 最后一页，没有下一页 -->
                    <c:if test="${pageCur != totalPage && totalPage != 0}">
                        <a href="${url_next}">下一页</a>
                    </c:if>
                </td>
            </tr>
            <tr>
                <td colspan="8">${message}</td>
            </tr>
        </table>
    </form>
</c:if>
</body>
</html>